package net.wanglu.www.zzz.service;

import java.io.InputStream;
import java.util.Properties;

import net.wanglu.www.zzz.service.se.__SentenceElements;
import net.wanglu.www.zzz.service.se.__SentenceExtracter;
import net.wanglu.www.zzz.service.se.rcmod._RcmodTuple;
import net.wanglu.www.zzz.service.sp.SentencePreprocess;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class _TestService {

	public static String[] appXmls = {"service-0.xml","service-sent.xml"};
	public static String test = "rcmod.properties";
	static int start = 1, end = 5;
	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		
        ApplicationContext ctx = new ClassPathXmlApplicationContext(appXmls);
		SentencePreprocess sp = (SentencePreprocess) ctx.getBean("SentencePreprocess");
		__SentenceExtracter ext = (__SentenceExtracter) ctx.getBean("__SentenceExtracter");
		
		Properties prop = new Properties();
		InputStream is = _TestService.class.getResourceAsStream(test);
		prop.load(is);
		
		for( int i=start; i<=end; i++) {
			String sentence = prop.getProperty(String.valueOf(i));
			Object preprocessData = sp.service(sentence);
			System.out.println(i);
			System.out.println(sentence);
			__SentenceElements se = (__SentenceElements) ext.service(preprocessData);
/*			for ( _NSubjTuple nst : se.NSubjTupleList) {
				System.out.println("subj:"+nst.getSubj());
				if ( nst.getSubjectAncestor() != null) {
					System.out.println("subjAncestor:"+nst.getSubjectAncestor());
				} else {
					System.out.println("subjAncestor:null");
				}
				System.out.println("verb:"+nst.getVerb());
				if ( nst.getVerbAncestor() != null) {
					System.out.println("verbAncestor:"+nst.getVerbAncestor());
				} else {
					System.out.println("verbAncestor:null");
				}
				System.out.println("aux:"+nst.getAux());
				System.out.println("cop:"+nst.getCop());

				if ( "expl".equals(nst.getRelation())) {
					System.out.println("there:"+nst.customize());
				} else if ( "rcmod".equals(nst.getRelation())) {
					System.out.println("rcmod:"+nst.customize());
				}
				System.out.println("---------------");
			}
			
			for( _ObjectTuple ot : se.ObjectTupleList) {
				System.out.println("obj:" + ot.getObject());
				System.out.println("objAncestor:" + ot.getObjectAncestor());
				System.out.println("objGov:" + ot.getObjectGov());
				System.out.println("objGovAncestor:" + ot.getObjectGovAncestor());
				System.out.println("---------------");
			}
			
			for( _PossTuple pt : se.PossTupleList) {
				System.out.println("headword:" + pt.getHeadword());
				System.out.println("possessive:" + pt.getPossessive());
				System.out.println("ancestor:" + pt.getAncestor());
				System.out.println("---------------");
			}	*/
			
			for( _RcmodTuple rt : se.RcmodTupleList) {
				System.out.println(rt);
				System.out.println("---------------");
			}
			System.out.println("**************");
		}
	}
}
